<script>
    Array.prototype.quickSort = function () {
        const rec =  (arr) => {
            // console.log();
            if(arr.length === 1){
                return arr;
            }
            let left = [];
            let right = [];
            let mid = arr[0];
            for(let i = 1; i < arr.length; i++){
                console.log(arr[i]); 
                if(arr[i]<mid){
                    left.push(arr[i])
                }else{
                    right.push(arr[i])
                }
            }
            return [...rec(left),mid,...rec(right)]
        }
        let res = rec(this)
        res.forEach((n,i)=>{this[i] = n})
    }
    // let arr2 = [19,3,9,90,1,32,20]
    let arr2 = [2,4,5,3,1]
    arr2.quickSort()
    console.log(arr2);
</script>